import { _decorator, Component, director, JsonAsset, Prefab } from 'cc';
import { WanderCfg } from './base/Defines';
import Log from './base/LogMgr';
import Timers from './base/TimerMgr';
const { ccclass, property } = _decorator;

export class App extends Component {

    // 游戏配置
    @property(JsonAsset)
    public gameCfg: JsonAsset = null!;

    // prefab 绑定关系
    @property(JsonAsset)
    public bundleInfo: JsonAsset = null!;

    // 文字提示
    @property(Prefab)
    public toastPfb: Prefab = null!;

    // 弹框遮罩
    @property(Prefab)
    public popupMaskPfb: Prefab = null!;

    // 请求遮罩
    @property(Prefab)
    public requestMaskPfb: Prefab = null!;

    // 加载预制体遮罩
    @property(Prefab)
    public loadingMaskPfb: Prefab = null!;

    // 网络连接预制体
    @property(Prefab)
    public websocketConnectingPfb: Prefab = null!;

    // 预加载预制体
    @property(Prefab)
    public preloadPfbs: Prefab[] = [];

    protected onLoad() {
        director.addPersistRootNode(this.node);

        const gameCfg = this.gameCfg.json as WanderCfg.IGame;
        const publishType = gameCfg.publishType;
        console.log(`Game ver: ${gameCfg.version}, mode: ${gameCfg.publishType}`);
        Log.setMode(publishType)
    }

    protected update(dt: number) {
        Timers.update(dt);
    }
}

